package persistence.jdbc;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class JDBC_Config {
	
	public static String STATE;	
	public static String URL; 
	public static String DBNAME;
	public static String USERNAME;
	public static String PASSWORD;

	/**
	 * set SQL server configuration parameters according to
	 * file jdbc_config.txt
	 */
	public static void SetConfig() {
		Properties prop = new Properties();
		try {
			prop.load(new FileInputStream("jdbc_config.txt"));
		} catch (FileNotFoundException e) {
			System.out.println(e.getMessage());
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}
		STATE = prop.getProperty("current_state");
		URL = prop.getProperty(STATE+"_url");
		DBNAME = prop.getProperty(STATE+"_db");
		USERNAME = prop.getProperty(STATE+"_username");
		PASSWORD = prop.getProperty(STATE+"_password");
	}	
}
